package com.ruoyi.quartz.task.workbench;

import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.workbench.domain.WbContract;
import com.ruoyi.workbench.service.IWbContractService;
import com.ruoyi.workbench.utils.SmsHelper;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component("contractTask")
public class ContractTask {
    /**
     * 检查快到期的合同，并且发出提醒
     */
    public void checkExpire() {
        //检测快过期的合同
        IWbContractService contractService = SpringUtils.getBean(IWbContractService.class);
        WbContract wbContract = new WbContract();
        wbContract.setDelFlag("0");
        Map<Integer, List<WbContract>> expireMap = contractService.selectExpireWbContractsMap();

        //检索可用手机号码
        /*IWbPhoneService phoneService = SpringUtils.getBean(IWbPhoneService.class);
        WbPhone phone = new WbPhone();
        phone.setPhoneStatus(0);
        List<WbPhone> phoneList = phoneService.selectWbPhoneList(phone);*/
        expireMap.forEach((month, contractList) -> SmsHelper.sendSmses(contractList));
    }
}
